import 'package:environmental_les_app/common/routes/route_names.dart';
import 'package:environmental_les_app/common/style/colours.dart';
import 'package:environmental_les_app/common/widgets/search_entry_widget.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart';

import 'index.dart';
import 'widgets/item_member_widget.dart';
import 'widgets/search_input_view.dart';

class AddressBookPage extends GetView<AddressBookController> {
  const AddressBookPage({super.key});

  // 主视图
  Widget _buildView() {
    return Column(
      children: [
        InkWell(
            onTap: () => Get.to(() => const SearchInputView()),
            child: const SearchEntryWidget(hintText: "搜索联系人")),
        vGap10,
        InkWell(
          onTap: () {
            Get.toNamed(AppRoutes.organizationPage);
          },
          child: Container(
            margin: const EdgeInsets.symmetric(horizontal: 10),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(8),
            ),
            padding: const EdgeInsets.all(12),
            child: Row(
              children: [
                ImageWidget.loadAssetImage("ic_book_frame",
                    width: 40, height: 40),
                hGap10,
                const Text(
                  "组织架构",
                  style: TextStyle(
                      color: Colours.textC4C,
                      fontSize: 16,
                      fontWeight: FontWeight.w500),
                ),
                const Spacer(),
                const Icon(
                  Icons.arrow_forward_ios,
                  size: 15,
                  color: Colours.text09C,
                )
              ],
            ),
          ),
        ),
        vGap10,
        const Row(
          children: [
            hGap20,
            Text(
              "常用联系人",
              style: TextStyle(
                color: Colours.text254,
                fontSize: 15,
              ),
            ),
          ],
        ),
        Column(
          children: [
            _buildContactItem(),
            _buildContactItem(),
            _buildContactItem(),
          ],
        )
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<AddressBookController>(
      init: AddressBookController(),
      id: "address_book",
      builder: (_) {
        return MyScaffold(
          title: "通讯录",
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }

  // 常用联系人 item
  Widget _buildContactItem() {
    return const ItemMemberWidget();
  }
}
